package model;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "Sach")
public class Sach {
	private int id_Sach;
	private String tenSach;
	private int giaBan;
	private String hinhAnh;
	private int soTrang;
	private String moTa;
	private int soLuong;
	private TheLoai theLoai;
	private int soLuongBan;
//	private Set<NhaXuatBan> nhaXuatBan = new HashSet<NhaXuatBan>(0);
//	private Set<TacGia> tacGia = new HashSet<TacGia>(0);
//	private Set<DichGia> dichGia = new HashSet<DichGia>(0);

	public Sach() {

	}

	public Sach(int id_Sach, String tenSach, int giaBan, String hinhAnh,
			int soTrang, String moTa, int soLuong, TheLoai theLoai, int soLuongBan) {
		super();
		this.id_Sach = id_Sach;
		this.tenSach = tenSach;
		this.giaBan = giaBan;
		this.hinhAnh = hinhAnh;
		this.soTrang = soTrang;
		this.moTa = moTa;
		this.soLuong = soLuong;
		this.theLoai = theLoai;
		this.soLuongBan = soLuongBan;
	}

	public Sach(int id_Sach, String tenSach, int giaBan, String hinhAnh,
			int soTrang, String moTa, int soLuong, TheLoai theLoai) {
		super();
		this.id_Sach = id_Sach;
		this.tenSach = tenSach;
		this.giaBan = giaBan;
		this.hinhAnh = hinhAnh;
		this.soTrang = soTrang;
		this.moTa = moTa;
		this.soLuong = soLuong;
		this.theLoai = theLoai;
	}
	
	
	public Sach(String tenSach, int giaBan, String hinhAnh, int soTrang,
			String moTa, int soLuong, TheLoai theLoai) {
		super();
		this.tenSach = tenSach;
		this.giaBan = giaBan;
		this.hinhAnh = hinhAnh;
		this.soTrang = soTrang;
		this.moTa = moTa;
		this.soLuong = soLuong;
		this.theLoai = theLoai;
	}


	@Id
	@GeneratedValue(generator = "Sach_ID_Gen", strategy = GenerationType.IDENTITY)
	@SequenceGenerator(name = "Sach_ID_Gen", sequenceName = "Sach_SEQ_ID")
	@Column(name = "ID_Sach", unique = true, nullable = false)
	public int getId_Sach() {
		return id_Sach;
	}

	public void setId_Sach(int id_Sach) {
		this.id_Sach = id_Sach;
	}

	@Column(name = "TenSach", nullable = false)
	public String getTenSach() {
		return tenSach;
	}

	public void setTenSach(String tenSach) {
		this.tenSach = tenSach;
	}

	@Column(name = "GiaBan", nullable = false)
	public int getGiaBan() {
		return giaBan;
	}

	public void setGiaBan(int giaBan) {
		this.giaBan = giaBan;
	}

	@Column(name = "HinhAnh")
	public String getHinhAnh() {
		return hinhAnh;
	}

	public void setHinhAnh(String hinhAnh) {
		this.hinhAnh = hinhAnh;
	}

	@Column(name = "SoTrang")
	public int getSoTrang() {
		return soTrang;
	}

	public void setSoTrang(int soTrang) {
		this.soTrang = soTrang;
	}

	@Column(name = "Mota")
	public String getMoTa() {
		return moTa;
	}

	public void setMoTa(String moTa) {
		this.moTa = moTa;
	}

	@Column(name = "SoLuong")
	public int getSoLuong() {
		return soLuong;
	}

	public void setSoLuong(int soLuong) {
		this.soLuong = soLuong;
	}

	@ManyToOne
	@JoinColumn(name = "ID_TheLoai")
	public TheLoai getTheLoai() {
		return theLoai;
	}

	public void setTheLoai(TheLoai theLoai) {
		this.theLoai = theLoai;
	}
	
	@Column(name = "soLuongBan")
	public int getSoLuongBan() {
		return soLuongBan;
	}

	public void setSoLuongBan(int soLuongBan) {
		this.soLuongBan = soLuongBan;
	}

//	@ManyToMany
//	@JoinTable(name = "ChiTietSach_NXB", joinColumns = @JoinColumn(name = "ID_Sach"), inverseJoinColumns = @JoinColumn(name = "ID_NXB"))
//	public Set<NhaXuatBan> getNhaXuatBan() {
//		return nhaXuatBan;
//	}
//
//	public void setNhaXuatBan(Set<NhaXuatBan> nhaXuatBan) {
//		this.nhaXuatBan = nhaXuatBan;
//	}

//	@ManyToMany
//	@JoinTable(name = "ChiTietSach_TacGia", joinColumns = @JoinColumn(name = "ID_Sach"), inverseJoinColumns = @JoinColumn(name = "ID_TacGia"))
//	public Set<TacGia> getTacGia() {
//		return tacGia;
//	}
//
//	public void setTacGia(Set<TacGia> tacGia) {
//		this.tacGia = tacGia;
//	}
//
//	@ManyToMany
//	@JoinTable(name = "ChiTietSach_DichGia", joinColumns = @JoinColumn(name = "ID_Sach"), inverseJoinColumns = @JoinColumn(name = "ID_DichGia"))
//	public Set<DichGia> getDichGia() {
//		return dichGia;
//	}
//
//	public void setDichGia(Set<DichGia> dichGia) {
//		this.dichGia = dichGia;
//	}

	
	
	
	
	
//	public List<Sach> listSach() {
//		List<Sach> list = new ArrayList<Sach>();
//		TheLoai tl1 = new TheLoai(1, "Mô tả 1", "Sách Tổng Hợp");
//		Sach sach2 = new Sach("Phương Thức ToYoTa", 69000,
//				"/images/bookimages/0.jpg", 200, "Mô tả 1", 50, tl1);
//		list.add(sach2);
//		return list;
//
//	}

}
